package com.ehsunbehravesh.varzesh3.gui;

import com.ehsunbehravesh.varzesh3.net.Ranking;
import com.ehsunbehravesh.varzesh3.net.RankingNode;
import javax.swing.event.TableModelListener;
import javax.swing.table.TableModel;

/**
 *
 * @author ehsun.behravesh
 */
public class RankingTableModel implements TableModel {

  private Ranking table;

  public RankingTableModel(Ranking table) {
    this.table = table;
  }

  @Override
  public int getRowCount() {
    return table.getTable().size();
  }

  @Override
  public int getColumnCount() {
    return 10;
  }

  @Override
  public String getColumnName(int columnIndex) {
    switch (columnIndex) {
      case 0:
        return "ردیف";
      case 1:
        return "تیم";
      case 2:
        return "بازی";
      case 3:
        return "برد";
      case 4:
        return "مساوی";
      case 5:
        return "باخت";
      case 6:
        return "گل زده";
      case 7:
        return "گل خرده";
      case 8:
        return "تفاضل گل";
      case 9:
        return "امتیاز";
      default:
        return "";
    }
  }

  @Override
  public Class<?> getColumnClass(int columnIndex) {
    return String.class;
  }

  @Override
  public boolean isCellEditable(int rowIndex, int columnIndex) {
    return false;
  }

  @Override
  public Object getValueAt(int rowIndex, int columnIndex) {
    RankingNode node = table.getTable().get(rowIndex);
    switch (columnIndex) {
      case 0:
        return rowIndex + 1;
      case 1:
        return node.getTeam();
      case 2:
        return node.getMatches();
      case 3:
        return node.getWins();
      case 4:
        return node.getDraws();
      case 5:
        return node.getLooses();
      case 6:
        return node.getScoredGoals();
      case 7:
        return node.getReceivedGoals();
      case 8:
        return node.getDifferentGoals();
      case 9:
        return node.getPoints();
      default:
        return "";
    }
  }

  @Override
  public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
  }

  @Override
  public void addTableModelListener(TableModelListener l) {
    
  }

  @Override
  public void removeTableModelListener(TableModelListener l) {

  }
}
